DOI

https://doi.org/10.5281/zenodo.3635430

https://osf.io/3tjfk/

Histopathology Research Template 🔬


1 Introduction

  • State the marker of interest, the study objectives, and hypotheses (Knijn, Simmer, and Nagtegaal 2015).1

2 Materials & Methods

Describe Materials and Methods as highlighted in (Knijn, Simmer, and Nagtegaal 2015).2

  • Describe patient characteristics, and inclusion and exclusion criteria

  • Describe treatment details

  • Describe the type of material used

  • Specify how expression of the biomarker was assessed

  • Describe the number of independent (blinded) scorers and how they scored

  • State the method of case selection, study design, origin of the cases, and time frame

  • Describe the end of the follow-up period and median follow-up time

  • Define all clinical endpoints examined

  • Specify all applied statistical methods

  • Describe how interactions with other clinical/pathological factors were analyzed


2.1 Header Codes

Codes for general settings.3

Setup global chunk settings4

knitr::opts_chunk$set(
    eval = TRUE,
    echo = TRUE,
    fig.path = here::here("figs/"),
    message = FALSE,
    warning = FALSE,
    error = FALSE,
    cache = FALSE,
    comment = NA,
    tidy = TRUE,
    fig.width = 6,
    fig.height = 4
)

Load Library

see R/loadLibrary.R for the libraries loaded.

source(file = here::here("R", "loadLibrary.R"))

2.2 Generate Fake Data

Codes for generating fake data.5

Generate Fake Data

This code generates a fake histopathological data. Some sources for fake data generation here6 , here7 , here8 , here9 , here10 , here11 , here12 , here13 , and here14 .

Use this code to generate fake clinicopathologic data

source(file = here::here("R", "gc_fake_data.R"))
wakefield::table_heat(x = fakedata, palette = "Set1", flip = TRUE, print = TRUE)


2.3 Import Data

Codes for importing data.15

Read the data

library(readxl)
mydata <- readxl::read_excel(here::here("data", "mydata.xlsx"))
# View(mydata) # Use to view data after importing

Add code for import multiple data purrr reduce


2.4 Study Population

2.4.1 Report General Features

Codes for reporting general features.16

Dataframe Report

# Dataframe report
mydata %>% select(-contains("Date")) %>% report::report(.)
The data contains 250 observations of the following variables:
  - ID: 250 entries: 001, n = 1; 002, n = 1; 003, n = 1 and 247 others
  - Name: 249 entries: Aahaan, n = 1; Abdihamid, n = 1; Abdulkarim, n = 1 and 246 others (1 missing)
  - Sex: 2 entries: Female, n = 139; Male, n = 110 (1 missing)
  - Age: Mean = 50.09, SD = 14.54, range = [25, 73], 1 missing
  - Race: 6 entries: White, n = 165; Hispanic, n = 37; Black, n = 33 and 3 others (1 missing)
  - PreinvasiveComponent: 2 entries: Absent, n = 193; Present, n = 56 (1 missing)
  - LVI: 2 entries: Absent, n = 161; Present, n = 89
  - PNI: 2 entries: Absent, n = 169; Present, n = 80 (1 missing)
  - Death: 2 levels: FALSE (n = 64); TRUE (n = 185) and missing (n = 1)
  - Group: 2 entries: Treatment, n = 137; Control, n = 112 (1 missing)
  - Grade: 3 entries: 3, n = 112; 2, n = 71; 1, n = 66 (1 missing)
  - TStage: 4 entries: 4, n = 108; 3, n = 85; 2, n = 37 and 1 other
  - AntiX_intensity: Mean = 2.38, SD = 0.66, range = [1, 3], 1 missing
  - AntiY_intensity: Mean = 2.02, SD = 0.76, range = [1, 3], 1 missing
  - LymphNodeMetastasis: 2 entries: Absent, n = 158; Present, n = 91 (1 missing)
  - Valid: 2 levels: FALSE (n = 119); TRUE (n = 130) and missing (n = 1)
  - Smoker: 2 levels: FALSE (n = 115); TRUE (n = 134) and missing (n = 1)
  - Grade_Level: 3 entries: high, n = 110; moderate, n = 77; low, n = 62 (1 missing)
  - DeathTime: 2 entries: Within1Year, n = 148; MoreThan1Year, n = 102
mydata %>% explore::describe_tbl()
250 observations with 21 variables
17 variables containing missings (NA)
0 variables with no variance

2.5 Ethics and IRB

2.5.1 Always Respect Patient Privacy

Always Respect Patient Privacy
- Health Information Privacy17
- Kişisel Verilerin Korunması18


2.6 Define Variable Types

Codes for defining variable types.19

2.6.1 Find Key Columns

print column names as vector

dput(names(mydata))
c("ID", "Name", "Sex", "Age", "Race", "PreinvasiveComponent", 
"LVI", "PNI", "LastFollowUpDate", "Death", "Group", "Grade", 
"TStage", "AntiX_intensity", "AntiY_intensity", "LymphNodeMetastasis", 
"Valid", "Smoker", "Grade_Level", "SurgeryDate", "DeathTime")

2.6.1.1 Find ID and key columns to exclude from analysis

See the code as function in R/find_key.R.

keycolumns <- mydata %>% sapply(., FUN = dataMaid::isKey) %>% as_tibble() %>% select(which(.[1, 
    ] == TRUE)) %>% names()
keycolumns
[1] "ID"   "Name"

2.6.2 Variable Types

Get variable types

mydata %>% select(-keycolumns) %>% inspectdf::inspect_types()
# A tibble: 4 x 4
  type             cnt  pcnt col_name  
  <chr>          <int> <dbl> <list>    
1 character         11  57.9 <chr [11]>
2 logical            3  15.8 <chr [3]> 
3 numeric            3  15.8 <chr [3]> 
4 POSIXct POSIXt     2  10.5 <chr [2]> 
mydata %>% select(-keycolumns, -contains("Date")) %>% describer::describe() %>% knitr::kable(format = "markdown")
.column_name .column_class .column_type .count_elements .mean_value .sd_value .q0_value .q25_value .q50_value .q75_value .q100_value
Sex character character 250 NA NA Female NA NA NA Male
Age numeric double 250 50.092369 14.5439927 25 38 51 63 73
Race character character 250 NA NA Asian NA NA NA White
PreinvasiveComponent character character 250 NA NA Absent NA NA NA Present
LVI character character 250 NA NA Absent NA NA NA Present
PNI character character 250 NA NA Absent NA NA NA Present
Death logical logical 250 NA NA FALSE NA NA NA TRUE
Group character character 250 NA NA Control NA NA NA Treatment
Grade character character 250 NA NA 1 NA NA NA 3
TStage character character 250 NA NA 1 NA NA NA 4
AntiX_intensity numeric double 250 2.381526 0.6622147 1 2 2 3 3
AntiY_intensity numeric double 250 2.024096 0.7616181 1 1 2 3 3
LymphNodeMetastasis character character 250 NA NA Absent NA NA NA Present
Valid logical logical 250 NA NA FALSE NA NA NA TRUE
Smoker logical logical 250 NA NA FALSE NA NA NA TRUE
Grade_Level character character 250 NA NA high NA NA NA moderate
DeathTime character character 250 NA NA MoreThan1Year NA NA NA Within1Year

Plot variable types

mydata %>% select(-keycolumns) %>% inspectdf::inspect_types() %>% inspectdf::show_plot()

# https://github.com/ropensci/visdat
# http://visdat.njtierney.com/articles/using_visdat.html
# https://cran.r-project.org/web/packages/visdat/index.html
# http://visdat.njtierney.com/

# visdat::vis_guess(mydata)

visdat::vis_dat(mydata)

mydata %>% explore::explore_tbl()

2.6.3 Define Variable Types

2.6.3.1 Find character variables

characterVariables <- mydata %>% select(-keycolumns) %>% inspectdf::inspect_types() %>% 
    dplyr::filter(type == "character") %>% dplyr::select(col_name) %>% pull() %>% 
    unlist()

characterVariables
 [1] "Sex"                  "Race"                 "PreinvasiveComponent"
 [4] "LVI"                  "PNI"                  "Group"               
 [7] "Grade"                "TStage"               "LymphNodeMetastasis" 
[10] "Grade_Level"          "DeathTime"           

2.6.3.2 Find categorical variables

categoricalVariables <- mydata %>% dplyr::select(-keycolumns, -contains("Date")) %>% 
    describer::describe() %>% janitor::clean_names() %>% dplyr::filter(column_type == 
    "factor") %>% dplyr::select(column_name) %>% dplyr::pull()

categoricalVariables
character(0)

2.6.3.3 Find continious variables

continiousVariables <- mydata %>% dplyr::select(-keycolumns, -contains("Date")) %>% 
    describer::describe() %>% janitor::clean_names() %>% dplyr::filter(column_type == 
    "numeric" | column_type == "double") %>% dplyr::select(column_name) %>% dplyr::pull()

continiousVariables
[1] "Age"             "AntiX_intensity" "AntiY_intensity"

2.6.3.4 Find numeric variables

numericVariables <- mydata %>% select(-keycolumns) %>% inspectdf::inspect_types() %>% 
    dplyr::filter(type == "numeric") %>% dplyr::select(col_name) %>% pull() %>% unlist()

numericVariables
[1] "Age"             "AntiX_intensity" "AntiY_intensity"

2.6.3.5 Find integer variables

integerVariables <- mydata %>% select(-keycolumns) %>% inspectdf::inspect_types() %>% 
    dplyr::filter(type == "integer") %>% dplyr::select(col_name) %>% pull() %>% unlist()

integerVariables
NULL

2.6.3.6 Find list variables

listVariables <- mydata %>% select(-keycolumns) %>% inspectdf::inspect_types() %>% 
    dplyr::filter(type == "list") %>% dplyr::select(col_name) %>% pull() %>% unlist()
listVariables
NULL

2.6.3.7 Find date variables

is_date <- function(x) inherits(x, c("POSIXct", "POSIXt"))

dateVariables <- names(which(sapply(mydata, FUN = is_date) == TRUE))
dateVariables
[1] "LastFollowUpDate" "SurgeryDate"     

2.7 Overview the Data

Codes for overviewing the data.20

2.7.1 View Data

View(mydata)
reactable::reactable(data = mydata, sortable = TRUE, resizable = TRUE, filterable = TRUE, 
    searchable = TRUE, pagination = TRUE, paginationType = "numbers", showPageSizeOptions = TRUE, 
    highlight = TRUE, striped = TRUE, outlined = TRUE, compact = TRUE, wrap = FALSE, 
    showSortIcon = TRUE, showSortable = TRUE)

2.7.2 Overview / Exploratory Data Analysis (EDA)

Summary of Data via summarytools 📦

summarytools::view(summarytools::dfSummary(mydata %>% select(-keycolumns)))
if (!dir.exists(here::here("out"))) {
    dir.create(here::here("out"))
}

summarytools::view(x = summarytools::dfSummary(mydata %>% select(-keycolumns)), file = here::here("out", 
    "mydata_summary.html"))

Summary via dataMaid 📦

if (!dir.exists(here::here("out"))) {
    dir.create(here::here("out"))
}

dataMaid::makeDataReport(data = mydata, file = here::here("out", "dataMaid_mydata.Rmd"), 
    replace = TRUE, openResult = FALSE, render = FALSE, quiet = TRUE)

Summary via explore 📦

if (!dir.exists(here::here("out"))) {
    dir.create(here::here("out"))
}

mydata %>% select(-dateVariables) %>% explore::report(output_file = "mydata_report.html", 
    output_dir = here::here("out"))

Glimpse of Data

glimpse(mydata %>% select(-keycolumns, -dateVariables))
Observations: 250
Variables: 17
$ Sex                  <chr> "Male", "Male", "Female", "Male", "Female", "Mal…
$ Age                  <dbl> 26, 31, 44, 70, 38, 67, 65, 54, 49, 41, 26, 53, …
$ Race                 <chr> "White", "White", "White", "White", "White", "Wh…
$ PreinvasiveComponent <chr> "Absent", "Absent", "Absent", "Present", "Absent…
$ LVI                  <chr> "Absent", "Present", "Absent", "Present", "Absen…
$ PNI                  <chr> "Absent", "Absent", "Absent", "Absent", "Present…
$ Death                <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE,…
$ Group                <chr> "Treatment", "Control", "Treatment", "Treatment"…
$ Grade                <chr> "3", "3", "2", "3", "2", "1", "3", "3", "2", "3"…
$ TStage               <chr> "1", "4", "3", "4", "3", "4", "4", "4", "4", "3"…
$ AntiX_intensity      <dbl> 3, 2, 2, 3, 2, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, …
$ AntiY_intensity      <dbl> 3, 2, 3, 3, 1, 1, 2, 2, 2, 3, 3, 2, 2, 3, 3, 2, …
$ LymphNodeMetastasis  <chr> "Absent", "Absent", "Absent", "Absent", "Absent"…
$ Valid                <lgl> TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FA…
$ Smoker               <lgl> FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, T…
$ Grade_Level          <chr> "low", "moderate", "high", "low", "high", "moder…
$ DeathTime            <chr> "Within1Year", "Within1Year", "Within1Year", "Wi…
mydata %>% explore::describe()
# A tibble: 21 x 8
   variable             type     na na_pct unique   min  mean   max
   <chr>                <chr> <int>  <dbl>  <int> <dbl> <dbl> <dbl>
 1 ID                   chr       0    0      250    NA NA       NA
 2 Name                 chr       1    0.4    250    NA NA       NA
 3 Sex                  chr       1    0.4      3    NA NA       NA
 4 Age                  dbl       1    0.4     50    25 50.1     73
 5 Race                 chr       1    0.4      7    NA NA       NA
 6 PreinvasiveComponent chr       1    0.4      3    NA NA       NA
 7 LVI                  chr       0    0        2    NA NA       NA
 8 PNI                  chr       1    0.4      3    NA NA       NA
 9 LastFollowUpDate     dat       1    0.4     13    NA NA       NA
10 Death                lgl       1    0.4      3     0  0.74     1
# … with 11 more rows

Explore

explore::explore(mydata)

2.7.3 Control Data

Control Data if matching expectations

visdat::vis_expect(data = mydata, expectation = ~.x == -1, show_perc = TRUE)

visdat::vis_expect(mydata, ~.x >= 25)

See missing values

visdat::vis_miss(airquality, cluster = TRUE)

visdat::vis_miss(airquality, sort_miss = TRUE)

xray::anomalies(mydata)
$variables
               Variable   q qNA  pNA qZero pZero qBlank pBlank qInf pInf
1                 Valid 250   1 0.4%   119 47.6%      0      -    0    -
2                Smoker 250   1 0.4%   115   46%      0      -    0    -
3                 Death 250   1 0.4%    64 25.6%      0      -    0    -
4                   Sex 250   1 0.4%     0     -      0      -    0    -
5  PreinvasiveComponent 250   1 0.4%     0     -      0      -    0    -
6                   PNI 250   1 0.4%     0     -      0      -    0    -
7                 Group 250   1 0.4%     0     -      0      -    0    -
8   LymphNodeMetastasis 250   1 0.4%     0     -      0      -    0    -
9                 Grade 250   1 0.4%     0     -      0      -    0    -
10      AntiX_intensity 250   1 0.4%     0     -      0      -    0    -
11      AntiY_intensity 250   1 0.4%     0     -      0      -    0    -
12          Grade_Level 250   1 0.4%     0     -      0      -    0    -
13                 Race 250   1 0.4%     0     -      0      -    0    -
14     LastFollowUpDate 250   1 0.4%     0     -      0      -    0    -
15                  Age 250   1 0.4%     0     -      0      -    0    -
16          SurgeryDate 250   1 0.4%     0     -      0      -    0    -
17                 Name 250   1 0.4%     0     -      0      -    0    -
18                  LVI 250   0    -     0     -      0      -    0    -
19            DeathTime 250   0    -     0     -      0      -    0    -
20               TStage 250   0    -     0     -      0      -    0    -
21                   ID 250   0    -     0     -      0      -    0    -
   qDistinct      type anomalous_percent
1          3   Logical               48%
2          3   Logical             46.4%
3          3   Logical               26%
4          3 Character              0.4%
5          3 Character              0.4%
6          3 Character              0.4%
7          3 Character              0.4%
8          3 Character              0.4%
9          4 Character              0.4%
10         4   Numeric              0.4%
11         4   Numeric              0.4%
12         4 Character              0.4%
13         7 Character              0.4%
14        13 Timestamp              0.4%
15        50   Numeric              0.4%
16       219 Timestamp              0.4%
17       250 Character              0.4%
18         2 Character                 -
19         2 Character                 -
20         4 Character                 -
21       250 Character                 -

$problem_variables
 [1] Variable          q                 qNA               pNA              
 [5] qZero             pZero             qBlank            pBlank           
 [9] qInf              pInf              qDistinct         type             
[13] anomalous_percent problems         
<0 rows> (or 0-length row.names)
xray::distributions(mydata)
================================================================================

[1] "Ignoring variable LastFollowUpDate: Unsupported type for visualization."
[1] "Ignoring variable SurgeryDate: Unsupported type for visualization."

         Variable p_1 p_10 p_25 p_50 p_75 p_90 p_99
1 AntiX_intensity   1  1.8    2    2    3    3    3
2 AntiY_intensity   1    1    1    2    3    3    3
3             Age  25   30   38   51   63   70   73

2.7.4 Explore Data

Summary of Data via DataExplorer 📦

DataExplorer::plot_str(mydata)
DataExplorer::plot_str(mydata, type = "r")
DataExplorer::introduce(mydata)
# A tibble: 1 x 9
   rows columns discrete_columns continuous_colu… all_missing_col…
  <int>   <int>            <int>            <int>            <int>
1   250      21               18                3                0
# … with 4 more variables: total_missing_values <int>, complete_rows <int>,
#   total_observations <int>, memory_usage <dbl>
DataExplorer::plot_intro(mydata)

DataExplorer::plot_missing(mydata)

Drop columns

mydata2 <- DataExplorer::drop_columns(mydata, "TStage")
DataExplorer::plot_bar(mydata)

DataExplorer::plot_bar(mydata, with = "Death")

DataExplorer::plot_histogram(mydata)



3 Statistical Analysis

Learn these tests as highlighted in (Schmidt et al. 2017).21


4 Results

Write results as described in (Knijn, Simmer, and Nagtegaal 2015)22

  • Describe the number of patients included in the analysis and reason for dropout

  • Report patient/disease characteristics (including the biomarker of interest) with the number of missing values

  • Describe the interaction of the biomarker of interest with established prognostic variables

  • Include at least 90 % of initial cases included in univariate and multivariate analyses

  • Report the estimated effect (relative risk/odds ratio, confidence interval, and p value) in univariate analysis

  • Report the estimated effect (hazard rate/odds ratio, confidence interval, and p value) in multivariate analysis

  • Report the estimated effects (hazard ratio/odds ratio, confidence interval, and p value) of other prognostic factors included in multivariate analysis


4.1 Descriptive Statistics

Codes for Descriptive Statistics.23

4.1.1 Table One

Report Data properties via report 📦

mydata %>% dplyr::select(-dplyr::contains("Date")) %>% report::report()
The data contains 250 observations of the following variables:
  - ID: 250 entries: 001, n = 1; 002, n = 1; 003, n = 1 and 247 others
  - Name: 249 entries: Aahaan, n = 1; Abdihamid, n = 1; Abdulkarim, n = 1 and 246 others (1 missing)
  - Sex: 2 entries: Female, n = 139; Male, n = 110 (1 missing)
  - Age: Mean = 50.09, SD = 14.54, range = [25, 73], 1 missing
  - Race: 6 entries: White, n = 165; Hispanic, n = 37; Black, n = 33 and 3 others (1 missing)
  - PreinvasiveComponent: 2 entries: Absent, n = 193; Present, n = 56 (1 missing)
  - LVI: 2 entries: Absent, n = 161; Present, n = 89
  - PNI: 2 entries: Absent, n = 169; Present, n = 80 (1 missing)
  - Death: 2 levels: FALSE (n = 64); TRUE (n = 185) and missing (n = 1)
  - Group: 2 entries: Treatment, n = 137; Control, n = 112 (1 missing)
  - Grade: 3 entries: 3, n = 112; 2, n = 71; 1, n = 66 (1 missing)
  - TStage: 4 entries: 4, n = 108; 3, n = 85; 2, n = 37 and 1 other
  - AntiX_intensity: Mean = 2.38, SD = 0.66, range = [1, 3], 1 missing
  - AntiY_intensity: Mean = 2.02, SD = 0.76, range = [1, 3], 1 missing
  - LymphNodeMetastasis: 2 entries: Absent, n = 158; Present, n = 91 (1 missing)
  - Valid: 2 levels: FALSE (n = 119); TRUE (n = 130) and missing (n = 1)
  - Smoker: 2 levels: FALSE (n = 115); TRUE (n = 134) and missing (n = 1)
  - Grade_Level: 3 entries: high, n = 110; moderate, n = 77; low, n = 62 (1 missing)
  - DeathTime: 2 entries: Within1Year, n = 148; MoreThan1Year, n = 102

Table 1 via arsenal 📦

# cat(names(mydata), sep = " + \n")
library(arsenal)
tab1 <- arsenal::tableby(
  ~ Sex +
    Age +
    Race +
    PreinvasiveComponent +
    LVI +
    PNI +
    Death +
    Group +
    Grade +
    TStage +
    # `Anti-X-intensity` +
    # `Anti-Y-intensity` +
    LymphNodeMetastasis +
    Valid +
    Smoker +
    Grade_Level
  ,
  data = mydata 
)
summary(tab1)
Overall (N=250)
Sex
   N-Miss 1
   Female 139 (55.8%)
   Male 110 (44.2%)
Age
   N-Miss 1
   Mean (SD) 50.092 (14.544)
   Range 25.000 - 73.000
Race
   N-Miss 1
   Asian 6 (2.4%)
   Bi-Racial 4 (1.6%)
   Black 33 (13.3%)
   Hispanic 37 (14.9%)
   Native 4 (1.6%)
   White 165 (66.3%)
PreinvasiveComponent
   N-Miss 1
   Absent 193 (77.5%)
   Present 56 (22.5%)
LVI
   Absent 161 (64.4%)
   Present 89 (35.6%)
PNI
   N-Miss 1
   Absent 169 (67.9%)
   Present 80 (32.1%)
Death
   N-Miss 1
   FALSE 64 (25.7%)
   TRUE 185 (74.3%)
Group
   N-Miss 1
   Control 112 (45.0%)
   Treatment 137 (55.0%)
Grade
   N-Miss 1
   1 66 (26.5%)
   2 71 (28.5%)
   3 112 (45.0%)
TStage
   1 20 (8.0%)
   2 37 (14.8%)
   3 85 (34.0%)
   4 108 (43.2%)
LymphNodeMetastasis
   N-Miss 1
   Absent 158 (63.5%)
   Present 91 (36.5%)
Valid
   N-Miss 1
   FALSE 119 (47.8%)
   TRUE 130 (52.2%)
Smoker
   N-Miss 1
   FALSE 115 (46.2%)
   TRUE 134 (53.8%)
Grade_Level
   N-Miss 1
   high 110 (44.2%)
   low 62 (24.9%)
   moderate 77 (30.9%)

Table 1 via tableone 📦

library(tableone)
mydata %>% select(-keycolumns, -dateVariables) %>% tableone::CreateTableOne(data = .)
                                    
                                     Overall      
  n                                    250        
  Sex = Male (%)                       110 (44.2) 
  Age (mean (SD))                    50.09 (14.54)
  Race (%)                                        
     Asian                               6 ( 2.4) 
     Bi-Racial                           4 ( 1.6) 
     Black                              33 (13.3) 
     Hispanic                           37 (14.9) 
     Native                              4 ( 1.6) 
     White                             165 (66.3) 
  PreinvasiveComponent = Present (%)    56 (22.5) 
  LVI = Present (%)                     89 (35.6) 
  PNI = Present (%)                     80 (32.1) 
  Death = TRUE (%)                     185 (74.3) 
  Group = Treatment (%)                137 (55.0) 
  Grade (%)                                       
     1                                  66 (26.5) 
     2                                  71 (28.5) 
     3                                 112 (45.0) 
  TStage (%)                                      
     1                                  20 ( 8.0) 
     2                                  37 (14.8) 
     3                                  85 (34.0) 
     4                                 108 (43.2) 
  AntiX_intensity (mean (SD))         2.38 (0.66) 
  AntiY_intensity (mean (SD))         2.02 (0.76) 
  LymphNodeMetastasis = Present (%)     91 (36.5) 
  Valid = TRUE (%)                     130 (52.2) 
  Smoker = TRUE (%)                    134 (53.8) 
  Grade_Level (%)                                 
     high                              110 (44.2) 
     low                                62 (24.9) 
     moderate                           77 (30.9) 
  DeathTime = Within1Year (%)          148 (59.2) 

Descriptive Statistics of Continuous Variables

mydata %>% select(continiousVariables, numericVariables, integerVariables) %>% summarytools::descr(., 
    style = "rmarkdown")
print(summarytools::descr(mydata), method = "render", table.classes = "st-small")
mydata %>% summarytools::descr(., stats = "common", transpose = TRUE, headings = FALSE)
mydata %>% summarytools::descr(stats = "common") %>% summarytools::tb()
mydata$Sex %>% summarytools::freq(cumul = FALSE, report.nas = FALSE) %>% summarytools::tb()
mydata %>% explore::describe() %>% dplyr::filter(unique < 5)
# A tibble: 15 x 8
   variable             type     na na_pct unique   min  mean   max
   <chr>                <chr> <int>  <dbl>  <int> <dbl> <dbl> <dbl>
 1 Sex                  chr       1    0.4      3    NA NA       NA
 2 PreinvasiveComponent chr       1    0.4      3    NA NA       NA
 3 LVI                  chr       0    0        2    NA NA       NA
 4 PNI                  chr       1    0.4      3    NA NA       NA
 5 Death                lgl       1    0.4      3     0  0.74     1
 6 Group                chr       1    0.4      3    NA NA       NA
 7 Grade                chr       1    0.4      4    NA NA       NA
 8 TStage               chr       0    0        4    NA NA       NA
 9 AntiX_intensity      dbl       1    0.4      4     1  2.38     3
10 AntiY_intensity      dbl       1    0.4      4     1  2.02     3
11 LymphNodeMetastasis  chr       1    0.4      3    NA NA       NA
12 Valid                lgl       1    0.4      3     0  0.52     1
13 Smoker               lgl       1    0.4      3     0  0.54     1
14 Grade_Level          chr       1    0.4      4    NA NA       NA
15 DeathTime            chr       0    0        2    NA NA       NA
mydata %>% explore::describe() %>% dplyr::filter(na > 0)
# A tibble: 17 x 8
   variable             type     na na_pct unique   min  mean   max
   <chr>                <chr> <int>  <dbl>  <int> <dbl> <dbl> <dbl>
 1 Name                 chr       1    0.4    250    NA NA       NA
 2 Sex                  chr       1    0.4      3    NA NA       NA
 3 Age                  dbl       1    0.4     50    25 50.1     73
 4 Race                 chr       1    0.4      7    NA NA       NA
 5 PreinvasiveComponent chr       1    0.4      3    NA NA       NA
 6 PNI                  chr       1    0.4      3    NA NA       NA
 7 LastFollowUpDate     dat       1    0.4     13    NA NA       NA
 8 Death                lgl       1    0.4      3     0  0.74     1
 9 Group                chr       1    0.4      3    NA NA       NA
10 Grade                chr       1    0.4      4    NA NA       NA
11 AntiX_intensity      dbl       1    0.4      4     1  2.38     3
12 AntiY_intensity      dbl       1    0.4      4     1  2.02     3
13 LymphNodeMetastasis  chr       1    0.4      3    NA NA       NA
14 Valid                lgl       1    0.4      3     0  0.52     1
15 Smoker               lgl       1    0.4      3     0  0.54     1
16 Grade_Level          chr       1    0.4      4    NA NA       NA
17 SurgeryDate          dat       1    0.4    219    NA NA       NA
mydata %>% explore::describe()
# A tibble: 21 x 8
   variable             type     na na_pct unique   min  mean   max
   <chr>                <chr> <int>  <dbl>  <int> <dbl> <dbl> <dbl>
 1 ID                   chr       0    0      250    NA NA       NA
 2 Name                 chr       1    0.4    250    NA NA       NA
 3 Sex                  chr       1    0.4      3    NA NA       NA
 4 Age                  dbl       1    0.4     50    25 50.1     73
 5 Race                 chr       1    0.4      7    NA NA       NA
 6 PreinvasiveComponent chr       1    0.4      3    NA NA       NA
 7 LVI                  chr       0    0        2    NA NA       NA
 8 PNI                  chr       1    0.4      3    NA NA       NA
 9 LastFollowUpDate     dat       1    0.4     13    NA NA       NA
10 Death                lgl       1    0.4      3     0  0.74     1
# … with 11 more rows

4.1.2 Categorical Variables

Use R/gc_desc_cat.R to generate gc_desc_cat.Rmd containing descriptive statistics for categorical variables

source(here::here("R", "gc_desc_cat.R"))

4.1.2.1 Descriptive Statistics Sex

mydata %>% janitor::tabyl(Sex) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
Sex n percent valid_percent
Female 139 55.6% 55.8%
Male 110 44.0% 44.2%
NA 1 0.4% -

4.1.2.2 Descriptive Statistics Race

mydata %>% janitor::tabyl(Race) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
Race n percent valid_percent
Asian 6 2.4% 2.4%
Bi-Racial 4 1.6% 1.6%
Black 33 13.2% 13.3%
Hispanic 37 14.8% 14.9%
Native 4 1.6% 1.6%
White 165 66.0% 66.3%
NA 1 0.4% -

4.1.2.3 Descriptive Statistics PreinvasiveComponent

mydata %>% janitor::tabyl(PreinvasiveComponent) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
PreinvasiveComponent n percent valid_percent
Absent 193 77.2% 77.5%
Present 56 22.4% 22.5%
NA 1 0.4% -

4.1.2.4 Descriptive Statistics LVI

mydata %>% janitor::tabyl(LVI) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
LVI n percent
Absent 161 64.4%
Present 89 35.6%

4.1.2.5 Descriptive Statistics PNI

mydata %>% janitor::tabyl(PNI) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
PNI n percent valid_percent
Absent 169 67.6% 67.9%
Present 80 32.0% 32.1%
NA 1 0.4% -

4.1.2.6 Descriptive Statistics Group

mydata %>% janitor::tabyl(Group) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
Group n percent valid_percent
Control 112 44.8% 45.0%
Treatment 137 54.8% 55.0%
NA 1 0.4% -

4.1.2.7 Descriptive Statistics Grade

mydata %>% janitor::tabyl(Grade) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
Grade n percent valid_percent
1 66 26.4% 26.5%
2 71 28.4% 28.5%
3 112 44.8% 45.0%
NA 1 0.4% -

4.1.2.8 Descriptive Statistics TStage

mydata %>% janitor::tabyl(TStage) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
TStage n percent
1 20 8.0%
2 37 14.8%
3 85 34.0%
4 108 43.2%

4.1.2.9 Descriptive Statistics LymphNodeMetastasis

mydata %>% janitor::tabyl(LymphNodeMetastasis) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
LymphNodeMetastasis n percent valid_percent
Absent 158 63.2% 63.5%
Present 91 36.4% 36.5%
NA 1 0.4% -

4.1.2.10 Descriptive Statistics Grade_Level

mydata %>% janitor::tabyl(Grade_Level) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
Grade_Level n percent valid_percent
high 110 44.0% 44.2%
low 62 24.8% 24.9%
moderate 77 30.8% 30.9%
NA 1 0.4% -

4.1.2.11 Descriptive Statistics DeathTime

mydata %>% janitor::tabyl(DeathTime) %>% janitor::adorn_pct_formatting(rounding = "half up", 
    digits = 1) %>% knitr::kable()
DeathTime n percent
MoreThan1Year 102 40.8%
Within1Year 148 59.2%
race_stats <- summarytools::freq(mydata$Race)
print(race_stats, report.nas = FALSE, totals = FALSE, display.type = FALSE, Variable.label = "Race Group")
mydata %>% explore::describe(PreinvasiveComponent)
variable = PreinvasiveComponent
type     = character
na       = 1 of 250 (0.4%)
unique   = 3
 Absent  = 193 (77.2%)
 Present = 56 (22.4%)
 NA      = 1 (0.4%)
## Frequency or custom tables for categorical variables
SmartEDA::ExpCTable(mydata, Target = NULL, margin = 1, clim = 10, nlim = 5, round = 2, 
    bin = NULL, per = T)
               Variable         Valid Frequency Percent CumPercent
1                   Sex        Female       139    55.6       55.6
2                   Sex          Male       110    44.0       99.6
3                   Sex            NA         1     0.4      100.0
4                   Sex         TOTAL       250      NA         NA
5                  Race         Asian         6     2.4        2.4
6                  Race     Bi-Racial         4     1.6        4.0
7                  Race         Black        33    13.2       17.2
8                  Race      Hispanic        37    14.8       32.0
9                  Race            NA         1     0.4       32.4
10                 Race        Native         4     1.6       34.0
11                 Race         White       165    66.0      100.0
12                 Race         TOTAL       250      NA         NA
13 PreinvasiveComponent        Absent       193    77.2       77.2
14 PreinvasiveComponent            NA         1     0.4       77.6
15 PreinvasiveComponent       Present        56    22.4      100.0
16 PreinvasiveComponent         TOTAL       250      NA         NA
17                  LVI        Absent       161    64.4       64.4
18                  LVI       Present        89    35.6      100.0
19                  LVI         TOTAL       250      NA         NA
20                  PNI        Absent       169    67.6       67.6
21                  PNI            NA         1     0.4       68.0
22                  PNI       Present        80    32.0      100.0
23                  PNI         TOTAL       250      NA         NA
24                Group       Control       112    44.8       44.8
25                Group            NA         1     0.4       45.2
26                Group     Treatment       137    54.8      100.0
27                Group         TOTAL       250      NA         NA
28                Grade             1        66    26.4       26.4
29                Grade             2        71    28.4       54.8
30                Grade             3       112    44.8       99.6
31                Grade            NA         1     0.4      100.0
32                Grade         TOTAL       250      NA         NA
33               TStage             1        20     8.0        8.0
34               TStage             2        37    14.8       22.8
35               TStage             3        85    34.0       56.8
36               TStage             4       108    43.2      100.0
37               TStage         TOTAL       250      NA         NA
38  LymphNodeMetastasis        Absent       158    63.2       63.2
39  LymphNodeMetastasis            NA         1     0.4       63.6
40  LymphNodeMetastasis       Present        91    36.4      100.0
41  LymphNodeMetastasis         TOTAL       250      NA         NA
42          Grade_Level          high       110    44.0       44.0
43          Grade_Level           low        62    24.8       68.8
44          Grade_Level      moderate        77    30.8       99.6
45          Grade_Level            NA         1     0.4      100.0
46          Grade_Level         TOTAL       250      NA         NA
47            DeathTime MoreThan1Year       102    40.8       40.8
48            DeathTime   Within1Year       148    59.2      100.0
49            DeathTime         TOTAL       250      NA         NA
50      AntiX_intensity             1        25    10.0       10.0
51      AntiX_intensity             2       104    41.6       51.6
52      AntiX_intensity             3       120    48.0       99.6
53      AntiX_intensity            NA         1     0.4      100.0
54      AntiX_intensity         TOTAL       250      NA         NA
55      AntiY_intensity             1        69    27.6       27.6
56      AntiY_intensity             2       105    42.0       69.6
57      AntiY_intensity             3        75    30.0       99.6
58      AntiY_intensity            NA         1     0.4      100.0
59      AntiY_intensity         TOTAL       250      NA         NA
inspectdf::inspect_cat(mydata)
# A tibble: 16 x 5
   col_name               cnt common      common_pcnt levels            
   <chr>                <int> <chr>             <dbl> <named list>      
 1 Death                    3 TRUE               74   <tibble [3 × 3]>  
 2 DeathTime                2 Within1Year        59.2 <tibble [2 × 3]>  
 3 Grade                    4 3                  44.8 <tibble [4 × 3]>  
 4 Grade_Level              4 high               44   <tibble [4 × 3]>  
 5 Group                    3 Treatment          54.8 <tibble [3 × 3]>  
 6 ID                     250 001                 0.4 <tibble [250 × 3]>
 7 LVI                      2 Absent             64.4 <tibble [2 × 3]>  
 8 LymphNodeMetastasis      3 Absent             63.2 <tibble [3 × 3]>  
 9 Name                   250 Aahaan              0.4 <tibble [250 × 3]>
10 PNI                      3 Absent             67.6 <tibble [3 × 3]>  
11 PreinvasiveComponent     3 Absent             77.2 <tibble [3 × 3]>  
12 Race                     7 White              66   <tibble [7 × 3]>  
13 Sex                      3 Female             55.6 <tibble [3 × 3]>  
14 Smoker                   3 TRUE               53.6 <tibble [3 × 3]>  
15 TStage                   4 4                  43.2 <tibble [4 × 3]>  
16 Valid                    3 TRUE               52   <tibble [3 × 3]>  
inspectdf::inspect_cat(mydata)$levels$Group
# A tibble: 3 x 3
  value      prop   cnt
  <chr>     <dbl> <int>
1 Treatment 0.548   137
2 Control   0.448   112
3 <NA>      0.004     1

4.1.2.12 Split-Group Stats Categorical

library(summarytools)

grouped_freqs <- stby(data = mydata$Smoker, INDICES = mydata$Sex, FUN = freq, cumul = FALSE, 
    report.nas = FALSE)

grouped_freqs %>% tb(order = 2)

4.1.2.13 Grouped Categorical

summarytools::stby(list(x = mydata$LVI, y = mydata$LymphNodeMetastasis), mydata$PNI, 
    summarytools::ctable)
with(mydata, summarytools::stby(list(x = LVI, y = LymphNodeMetastasis), PNI, summarytools::ctable))
mydata %>% select(characterVariables) %>% select(PreinvasiveComponent, PNI, LVI) %>% 
    reactable::reactable(data = ., groupBy = c("PreinvasiveComponent", "PNI"), columns = list(LVI = reactable::colDef(aggregate = "count")))

4.1.3 Continious Variables

questionr:::icut()
source(here::here("R", "gc_desc_cont.R"))

Descriptive Statistics Age

mydata %>% jmv::descriptives(data = ., vars = "Age", hist = TRUE, dens = TRUE, box = TRUE, 
    violin = TRUE, dot = TRUE, mode = TRUE, sd = TRUE, variance = TRUE, skew = TRUE, 
    kurt = TRUE, quart = TRUE)

 DESCRIPTIVES

 Descriptives                       
 ────────────────────────────────── 
                          Age       
 ────────────────────────────────── 
   N                          249   
   Missing                      1   
   Mean                      50.1   
   Median                    51.0   
   Mode                      70.0   
   Standard deviation        14.5   
   Variance                   212   
   Minimum                   25.0   
   Maximum                   73.0   
   Skewness               -0.0856   
   Std. error skewness      0.154   
   Kurtosis                 -1.24   
   Std. error kurtosis      0.307   
   25th percentile           38.0   
   50th percentile           51.0   
   75th percentile           63.0   
 ────────────────────────────────── 

Descriptive Statistics AntiX_intensity

mydata %>% jmv::descriptives(data = ., vars = "AntiX_intensity", hist = TRUE, dens = TRUE, 
    box = TRUE, violin = TRUE, dot = TRUE, mode = TRUE, sd = TRUE, variance = TRUE, 
    skew = TRUE, kurt = TRUE, quart = TRUE)

 DESCRIPTIVES

 Descriptives                               
 ────────────────────────────────────────── 
                          AntiX_intensity   
 ────────────────────────────────────────── 
   N                                  249   
   Missing                              1   
   Mean                              2.38   
   Median                            2.00   
   Mode                              3.00   
   Standard deviation               0.662   
   Variance                         0.439   
   Minimum                           1.00   
   Maximum                           3.00   
   Skewness                        -0.606   
   Std. error skewness              0.154   
   Kurtosis                        -0.656   
   Std. error kurtosis              0.307   
   25th percentile                   2.00   
   50th percentile                   2.00   
   75th percentile                   3.00   
 ────────────────────────────────────────── 

Descriptive Statistics AntiY_intensity

mydata %>% jmv::descriptives(data = ., vars = "AntiY_intensity", hist = TRUE, dens = TRUE, 
    box = TRUE, violin = TRUE, dot = TRUE, mode = TRUE, sd = TRUE, variance = TRUE, 
    skew = TRUE, kurt = TRUE, quart = TRUE)

 DESCRIPTIVES

 Descriptives                               
 ────────────────────────────────────────── 
                          AntiY_intensity   
 ────────────────────────────────────────── 
   N                                  249   
   Missing                              1   
   Mean                              2.02   
   Median                            2.00   
   Mode                              2.00   
   Standard deviation               0.762   
   Variance                         0.580   
   Minimum                           1.00   
   Maximum                           3.00   
   Skewness                       -0.0405   
   Std. error skewness              0.154   
   Kurtosis                         -1.27   
   Std. error kurtosis              0.307   
   25th percentile                   1.00   
   50th percentile                   2.00   
   75th percentile                   3.00   
 ────────────────────────────────────────── 

tab <- tableone::CreateTableOne(data = mydata)
# ?print.ContTable
tab$ContTable
                             
                              Overall      
  n                           250          
  Age (mean (SD))             50.09 (14.54)
  AntiX_intensity (mean (SD))  2.38 (0.66) 
  AntiY_intensity (mean (SD))  2.02 (0.76) 
print(tab$ContTable, nonnormal = c("Anti-X-intensity"))
                             
                              Overall      
  n                           250          
  Age (mean (SD))             50.09 (14.54)
  AntiX_intensity (mean (SD))  2.38 (0.66) 
  AntiY_intensity (mean (SD))  2.02 (0.76) 
mydata %>% explore::describe(Age)
variable = Age
type     = double
na       = 1 of 250 (0.4%)
unique   = 50
min|max  = 25 | 73
q05|q95  = 27 | 71.6
q25|q75  = 38 | 63
median   = 51
mean     = 50.09237
mydata %>% select(continiousVariables) %>% SmartEDA::ExpNumStat(data = ., by = "A", 
    gp = NULL, Qnt = seq(0, 1, 0.1), MesofShape = 2, Outlier = TRUE, round = 2)
inspectdf::inspect_num(mydata, breaks = 10)
# A tibble: 3 x 10
  col_name        min    q1 median  mean    q3   max     sd pcnt_na hist        
  <chr>         <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl>  <dbl>   <dbl> <named list>
1 Age              25    38     51 50.1     63    73 14.5       0.4 <tibble [12…
2 AntiX_intens…     1     2      2  2.38     3     3  0.662     0.4 <tibble [12…
3 AntiY_intens…     1     1      2  2.02     3     3  0.762     0.4 <tibble [12…
inspectdf::inspect_num(mydata)$hist$Age
# A tibble: 27 x 2
   value        prop
   <chr>       <dbl>
 1 [-Inf, 24) 0     
 2 [24, 26)   0.0201
 3 [26, 28)   0.0442
 4 [28, 30)   0.0281
 5 [30, 32)   0.0522
 6 [32, 34)   0.0321
 7 [34, 36)   0.0402
 8 [36, 38)   0.0321
 9 [38, 40)   0.0361
10 [40, 42)   0.0402
# … with 17 more rows
inspectdf::inspect_num(mydata, breaks = 10) %>% inspectdf::show_plot()

4.1.3.1 Split-Group Stats Continious

grouped_descr <- summarytools::stby(data = mydata, INDICES = mydata$Sex, FUN = summarytools::descr, 
    stats = "common")
# grouped_descr %>% summarytools::tb(order = 2)
grouped_descr %>% summarytools::tb()

4.1.3.2 Grouped Continious

summarytools::stby(data = mydata, INDICES = mydata$PreinvasiveComponent, FUN = summarytools::descr, 
    stats = c("mean", "sd", "min", "med", "max"), transpose = TRUE)
with(mydata, summarytools::stby(Age, PreinvasiveComponent, summarytools::descr), 
    stats = c("mean", "sd", "min", "med", "max"), transpose = TRUE)
mydata %>% group_by(PreinvasiveComponent) %>% summarytools::descr(stats = "fivenum")
## Summary statistics by – category
SmartEDA::ExpNumStat(mydata, by = "GA", gp = "PreinvasiveComponent", Qnt = seq(0, 
    1, 0.1), MesofShape = 2, Outlier = TRUE, round = 2)
  Vname                        Group  TN nNeg nZero nPos NegInf PosInf NA_Value
1   Age     PreinvasiveComponent:All 250    0     0  249      0      0        1
2   Age  PreinvasiveComponent:Absent 193    0     0  193      0      0        0
3   Age PreinvasiveComponent:Present  56    0     0   55      0      0        1
4   Age      PreinvasiveComponent:NA   0    0     0    0      0      0        0
  Per_of_Missing   sum min  max  mean median    SD   CV  IQR Skewness Kurtosis
1           0.40 12473  25   73 50.09     51 14.54 0.29 25.0    -0.09    -1.24
2           0.00  9572  25   73 49.60     51 14.53 0.29 26.0    -0.08    -1.27
3           1.79  2865  26   73 52.09     52 14.57 0.28 22.5    -0.14    -1.14
4            NaN     0 Inf -Inf   NaN     NA    NA   NA   NA      NaN      NaN
  0%  10%  20%  30%  40% 50%  60%  70%  80%  90% 100% LB.25% UB.75% nOutliers
1 25 30.0 35.0 41.0 45.0  51 55.0 61.0 65.4 70.0   73   0.50 100.50         0
2 25 29.2 34.4 40.0 44.0  51 55.0 60.4 65.0 69.0   73  -2.00 102.00         0
3 26 31.4 36.6 43.4 48.6  52 56.4 61.8 69.2 71.6   73   6.75  96.75         0
4 NA   NA   NA   NA   NA  NA   NA   NA   NA   NA   NA     NA     NA         0

4.2 Survival Analysis

Codes for Survival Analysis24

  • Survival analysis with strata, clusters, frailties and competing risks in in Finalfit

https://www.datasurg.net/2019/09/12/survival-analysis-with-strata-clusters-frailties-and-competing-risks-in-in-finalfit/

  • Intracranial WHO grade I meningioma: a competing risk analysis of progression and disease-specific survival

https://link.springer.com/article/10.1007/s00701-019-04096-9

Calculate survival time

mydata$int <- lubridate::interval(lubridate::ymd(mydata$SurgeryDate), lubridate::ymd(mydata$LastFollowUpDate))
mydata$OverallTime <- lubridate::time_length(mydata$int, "month")
mydata$OverallTime <- round(mydata$OverallTime, digits = 1)

recode death status outcome as numbers for survival analysis

## Recoding mydata$Death into mydata$Outcome
mydata$Outcome <- forcats::fct_recode(as.character(mydata$Death), `1` = "TRUE", `0` = "FALSE")
mydata$Outcome <- as.numeric(as.character(mydata$Outcome))

it is always a good practice to double-check after recoding25

table(mydata$Death, mydata$Outcome)
       
          0   1
  FALSE  64   0
  TRUE    0 185

4.2.1 Kaplan-Meier

library(survival)
# data(lung) km <- with(lung, Surv(time, status))
km <- with(mydata, Surv(OverallTime, Outcome))
head(km, 80)
 [1]  3.7  11.0   7.0   3.2  10.6  10.4   8.9    NA+ 10.2   9.5   8.2   5.1 
[13]  7.0   3.0   5.0   9.4   7.3   9.8   4.2+ 10.9  11.3+  4.7+ 11.8+  3.1+
[25]  7.6+  8.2   8.8   3.0    NA+  6.2+ 10.8   7.8   9.4   6.2+ 10.7   7.1 
[37] 11.3+  4.0+  3.8   9.2   5.1  11.2   5.4   6.2   5.3   6.6   6.6   6.1 
[49]  3.9   5.2   9.3+  7.5   9.5+  6.4+ 10.6   3.8+  4.7  10.6   5.2  11.1 
[61]  3.0   5.6+  4.7+  6.4   7.2   7.0   5.0+  2.9+  5.0   4.9+  3.9   4.7 
[73] 10.8  10.8   8.4  11.4   4.3+  8.2+  4.7+  4.5+
plot(km)

Kaplan-Meier Plot Log-Rank Test

# Drawing Survival Curves Using ggplot2
# https://rpkgs.datanovia.com/survminer/reference/ggsurvplot.html
dependentKM <- "Surv(OverallTime, Outcome)"
explanatoryKM <- "LVI"

mydata %>%
  finalfit::surv_plot(.data = .,
                      dependent = dependentKM,
                      explanatory = explanatoryKM,
                      xlab='Time (months)',
                      pval=TRUE,
                      legend = 'none',
                      break.time.by = 12,
                      xlim = c(0,60)
                      # legend.labs = c('a','b')
                      )

# Drawing Survival Curves Using ggplot2
# https://rpkgs.datanovia.com/survminer/reference/ggsurvplot.html

mydata %>%
  finalfit::surv_plot(.data = .,
                      dependent = "Surv(OverallTime, Outcome)",
                      explanatory = "LVI",
                      xlab='Time (months)',
                      pval=TRUE,
                      legend = 'none',
                      break.time.by = 12,
                      xlim = c(0,60)
                      # legend.labs = c('a','b')
                      )

4.2.2 Univariate Cox-Regression

library(finalfit)
library(survival)
explanatoryUni <- "LVI"
dependentUni <- "Surv(OverallTime, Outcome)"

tUni <- mydata %>% finalfit::finalfit(dependentUni, explanatoryUni)

knitr::kable(tUni, row.names = FALSE, align = c("l", "l", "r", "r", "r", "r"))
Dependent: Surv(OverallTime, Outcome) all HR (univariable) HR (multivariable)
LVI Absent 161 (100.0) - -
Present 89 (100.0) 2.04 (1.49-2.80, p<0.001) 2.04 (1.49-2.80, p<0.001)
tUni_df <- tibble::as_tibble(tUni, .name_repair = "minimal") %>% janitor::clean_names()

tUni_df_descr <- paste0("When ", tUni_df$dependent_surv_overall_time_outcome[1], 
    " is ", tUni_df$x[2], ", there is ", tUni_df$hr_univariable[2], " times risk than ", 
    "when ", tUni_df$dependent_surv_overall_time_outcome[1], " is ", tUni_df$x[1], 
    ".")

When LVI is Present, there is 2.04 (1.49-2.80, p<0.001) times risk than when LVI is Absent.

4.2.3 Kaplan-Meier Median Survival

km_fit <- survfit(Surv(OverallTime, Outcome) ~ LVI, data = mydata)
km_fit
Call: survfit(formula = Surv(OverallTime, Outcome) ~ LVI, data = mydata)

   3 observations deleted due to missingness 
              n events median 0.95LCL 0.95UCL
LVI=Absent  158    121   20.7    13.5    26.4
LVI=Present  89     64   10.0     8.9    11.2
plot(km_fit)

# summary(km_fit)
km_fit_median_df <- summary(km_fit)
km_fit_median_df <- as.data.frame(km_fit_median_df$table) %>% janitor::clean_names() %>% 
    tibble::rownames_to_column()
km_fit_median_definition <- km_fit_median_df %>% dplyr::mutate(description = glue::glue("When {rowname}, median survival is {median} [{x0_95lcl} - {x0_95ucl}, 95% CI] months.")) %>% 
    dplyr::select(description) %>% pull()

When LVI=Absent, median survival is 20.7 [13.5 - 26.4, 95% CI] months., When LVI=Present, median survival is 10 [8.9 - 11.2, 95% CI] months.

4.2.4 1-3-5-yr survival

summary(km_fit, times = c(12, 36, 60))
Call: survfit(formula = Surv(OverallTime, Outcome) ~ LVI, data = mydata)

3 observations deleted due to missingness 
                LVI=Absent 
 time n.risk n.event survival std.err lower 95% CI upper 95% CI
   12     81      58    0.600  0.0409        0.524        0.685
   36     22      47    0.211  0.0372        0.150        0.299

                LVI=Present 
 time n.risk n.event survival std.err lower 95% CI upper 95% CI
   12     17      50   0.3112  0.0576       0.2165        0.447
   36      3      12   0.0741  0.0379       0.0272        0.202
km_fit_summary <- summary(km_fit, times = c(12, 36, 60))

km_fit_df <- as.data.frame(km_fit_summary[c("strata", "time", "n.risk", "n.event", 
    "surv", "std.err", "lower", "upper")])
km_fit_definition <- km_fit_df %>% dplyr::mutate(description = glue::glue("When {strata}, {time} month survival is {scales::percent(surv)} [{scales::percent(lower)}-{scales::percent(upper)}, 95% CI].")) %>% 
    dplyr::select(description) %>% pull()

When LVI=Absent, 12 month survival is 60.0% [52.4%-68.5%, 95% CI]., When LVI=Absent, 36 month survival is 21.1% [15.0%-29.9%, 95% CI]., When LVI=Present, 12 month survival is 31.1% [21.7%-44.7%, 95% CI]., When LVI=Present, 36 month survival is 7.4% [2.7%-20.2%, 95% CI].

4.2.5 Pairwise comparison

dependentKM <- "Surv(OverallTime, Outcome)"
explanatoryKM <- "TStage"

mydata %>%
  finalfit::surv_plot(.data = .,
                      dependent = dependentKM,
                      explanatory = explanatoryKM,
                      xlab='Time (months)',
                      pval=TRUE,
                      legend = 'none',
                      break.time.by = 12,
                      xlim = c(0,60)
                      # legend.labs = c('a','b')
                      )

km_fit
Call: survfit(formula = Surv(OverallTime, Outcome) ~ LVI, data = mydata)

   3 observations deleted due to missingness 
              n events median 0.95LCL 0.95UCL
LVI=Absent  158    121   20.7    13.5    26.4
LVI=Present  89     64   10.0     8.9    11.2
print(km_fit, 
      scale=1,
      digits = max(options()$digits - 4,3),
      print.rmean=getOption("survfit.print.rmean"),
      rmean = getOption('survfit.rmean'),
      print.median=getOption("survfit.print.median"),
      median = getOption('survfit.median')
      
      )
Call: survfit(formula = Surv(OverallTime, Outcome) ~ LVI, data = mydata)

   3 observations deleted due to missingness 
              n events median 0.95LCL 0.95UCL
LVI=Absent  158    121   20.7    13.5    26.4
LVI=Present  89     64   10.0     8.9    11.2

4.2.6 Multivariate Analysis Survival

5 parsnip



6 Discussion

  • Interpret the results in context of the working hypothesis elaborated in the introduction and other relevant studies; include a discussion of limitations of the study.

  • Discuss potential clinical applications and implications for future research

References

Knijn, N., F. Simmer, and I. D. Nagtegaal. 2015. “Recommendations for Reporting Histopathology Studies: A Proposal.” Virchows Archiv 466 (6): 611–15. https://doi.org/10.1007/s00428-015-1762-3.

Schmidt, Robert L., Deborah J. Chute, Jorie M. Colbert-Getz, Adolfo Firpo-Betancourt, Daniel S. James, Julie K. Karp, Douglas C. Miller, et al. 2017. “Statistical Literacy Among Academic Pathologists: A Survey Study to Gauge Knowledge of Frequently Used Statistical Tests Among Trainees and Faculty.” Archives of Pathology & Laboratory Medicine 141 (2): 279–87. https://doi.org/10.5858/arpa.2016-0200-OA.


  1. From Table 1: Proposed items for reporting histopathology studies. Recommendations for reporting histopathology studies: a proposal Virchows Arch (2015) 466:611–615 DOI 10.1007/s00428-015-1762-3 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4460276/↩︎

  2. From Table 1: Proposed items for reporting histopathology studies. Recommendations for reporting histopathology studies: a proposal Virchows Arch (2015) 466:611–615 DOI 10.1007/s00428-015-1762-3 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4460276/↩︎

  3. See childRmd/_01header.Rmd file for other general settings↩︎

  4. Change echo = FALSE to hide codes after knitting.↩︎

  5. See childRmd/_02fakeData.Rmd file for other codes↩︎

  6. Synthea The validity of synthetic clinical data: a validation study of a leading synthetic data generator (Synthea) using clinical quality measures. BMC Med Inform Decis Mak 19, 44 (2019) doi:10.1186/s12911-019-0793-0↩︎

  7. https://bmcmedinformdecismak.biomedcentral.com/articles/10.1186/s12911-019-0793-0↩︎

  8. Synthetic Patient Generation↩︎

  9. Basic Setup and Running↩︎

  10. intelligent patient data generator (iPDG)↩︎

  11. https://medium.com/free-code-camp/how-our-test-data-generator-makes-fake-data-look-real-ace01c5bde4a↩︎

  12. https://forums.librehealth.io/t/demo-data-generation/203↩︎

  13. https://mihin.org/services/patient-generator/↩︎

  14. lung, cancer, breast datası ile birleştir↩︎

  15. See childRmd/_03importData.Rmd file for other codes↩︎

  16. See childRmd/_04briefSummary.Rmd file for other codes↩︎

  17. https://www.hhs.gov/hipaa/index.html↩︎

  18. Kişisel verilerin kaydedilmesi ve kişisel verileri hukuka aykırı olarak verme veya ele geçirme Türk Ceza Kanunu’nun 135. ve 136. maddesi kapsamında bizim hukuk sistemimizde suç olarak tanımlanmıştır. Kişisel verilerin kaydedilmesi suçunun cezası 1 ila 3 yıl hapis cezasıdır. Suçun nitelikli hali ise, kamu görevlisi tarafından görevin verdiği yetkinin kötüye kullanılarak veya belirli bir meslek veya sanatın sağladığı kolaylıktan yararlanılarak işlenmesidir ki bu durumda suçun cezası 1.5 ile 4.5 yıl hapis cezası olacaktır.↩︎

  19. See childRmd/_06variableTypes.Rmd file for other codes↩︎

  20. See childRmd/_07overView.Rmd file for other codes↩︎

  21. Statistical Literacy Among Academic Pathologists: A Survey Study to Gauge Knowledge of Frequently Used Statistical Tests Among Trainees and Faculty. Archives of Pathology & Laboratory Medicine: February 2017, Vol. 141, No. 2, pp. 279-287. https://doi.org/10.5858/arpa.2016-0200-OA↩︎

  22. From Table 1: Proposed items for reporting histopathology studies. Recommendations for reporting histopathology studies: a proposal Virchows Arch (2015) 466:611–615 DOI 10.1007/s00428-015-1762-3 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4460276/↩︎

  23. See childRmd/_11descriptives.Rmd file for other codes↩︎

  24. See childRmd/_18survival.Rmd file for other codes, and childRmd/_19shinySurvival.Rmd for shiny application↩︎

  25. JAMA retraction after miscoding – new Finalfit function to check recoding↩︎

  26. See childRmd/_23footer.Rmd file for other codes↩︎

  27. Smith AM, Katz DS, Niemeyer KE, FORCE11 Software Citation Working Group. (2016) Software Citation Principles. PeerJ Computer Science 2:e86. DOI: 10.7717/peerj-cs.86 https://www.force11.org/software-citation-principles↩︎

 

A work by Serdar Balci

drserdarbalci@gmail.com